package thread;

public class Test {
	public static void main(String[] args) {
		Thread thread = new Mythread();
		for(int i=0; i<100; i++){
			System.out.println(i);
			sleep(1);
			if (i==20) {
				thread.start();//start代表异步执行run方法
				//thread.run();//run代表同步执行了方法
			}
		}
	}
	public static void sleep(int m) {
		try {
			Thread.sleep(m);
		} catch (InterruptedException e) {
			e.printStackTrace();
			// TODO: handle exception
		}
	}
}
class Mythread extends Thread{
	@Override
	public void run() {
		// TODO Auto-generated method stub
		for(int i=0; i<100; i++){
			System.out.println(i+"--new thread");
			Test.sleep(1);
		}
	}
}
